package com.booksmanager.controller;

import com.booksmanager.annotation.Log;
import com.booksmanager.utils.FileUpload;
import com.booksmanager.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ Author     ：Yan
 * @ Date       ：Created in 14:31 2020/5/20
 * @ Description：
 * @ Modified By：
 * @Version: $
 */

@Api(value = "/fileUpload", tags = "文件上传模块")
@RestController
@RequestMapping("/fileUpload")
public class FileUploadController {
    @Autowired
    private FileUpload fileUpload;
    /**
     * 普通上传
     */
    @ApiOperation(value = "上传file")
    @Log("上传file")
    @PostMapping("/upload")
    public R uploadFile(@RequestParam(value = "file", required = false) MultipartFile multipartFile) {
        return new R(fileUpload.singleUpload(multipartFile));
    }
}
